package xyz.chaobei;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;

/**
 * 实现servlet
 *
 * @author <a href='mailto:maruichao52@gmail.com'>MRC</a>
 * @since 2020/12/7
 */
public class HelloWorld extends HttpServlet {

    private Logger logger = LoggerFactory.getLogger(HelloWorld.class);

    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        logger.info("req session:" + req.getSession().toString());
        logger.info("req session id:" + req.getSession().getId());

        String hello = "Hello World";

        ServletOutputStream outputStream = resp.getOutputStream();

        outputStream.write(hello.getBytes());
        outputStream.flush();
        outputStream.close();
    }

}
